package com.crm.service.impl;

import com.crm.mapper.DictMapper;
import com.crm.pojo.common.DictResult;
import com.crm.pojo.common.PageResult;
import com.crm.pojo.dto.DictDto;
import com.crm.pojo.vo.DictTypeVo;
import com.crm.pojo.vo.DictVo;
import com.crm.service.DictService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictServiceImpl implements DictService {
    @Autowired
    private DictMapper dictMapper;
    //渠道来源
    @Override
    public List<DictVo> dict(String dictType) {

        return dictMapper.get(dictType);
    }


    @Override
    public PageResult page(DictDto dictDto) {
        PageHelper.startPage(dictDto.getPageNum(), dictDto.getPageSize());
        List<DictTypeVo> list = dictMapper.list(dictDto);
        Page page = (Page) list;
        PageResult pageResult = new PageResult<>();
        pageResult.setTotal(page.getTotal());
        pageResult.setRows(list);
        pageResult.setCode(200);
        pageResult.setMsg("查询成功");
        return pageResult;
    }
}
